﻿using LiveCharts;
using LiveCharts.Wpf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace BangumiWpfApp1
{
    /// <summary>
    /// RateTotalScoreView.xaml 的交互逻辑
    /// </summary>
    public partial class RateTotalScoreView : Window
    {
        public SeriesCollection RateTotalCollection { get; set; }
        public SeriesCollection ScoreCollection { get; set; }
        private int type;// 1 score   ; 2 RateTotal
        public void setType(int i)
        {
            type = i;
        }
        public RateTotalScoreView()
        {
            InitializeComponent();
            this.DataContext = this;

            BangumiApi bangumiApi = new BangumiApi();


            if (type == 1)
            {
                var dicScore = bangumiApi.scoreStatistics();
                List<int> scores = dicScore.Select(i => i.Value).ToList();
                ScoreCollection = new SeriesCollection
                {
                    new LineSeries
                    {
                        Values = new ChartValues<int>(scores)
                    }
                };        
            }
            else
            {
                var dicRateTotal = bangumiApi.scoreStatistics();
                List<int> rateTotal = dicRateTotal.Select(i => i.Value).ToList();
                ScoreCollection = new SeriesCollection
                {
                    new LineSeries
                    {
                        Values = new ChartValues<int>(rateTotal)
                    }
                };

            }

        }
    }
}
